
#ifndef __MXD_CMMBDemuxer_H__
#define __MXD_CMMBDemuxer_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _CMMBUNIT_DEFINE
{
	const MXD_INT8*		m_szNodeName;
	MXD_UINT32			m_nPresetNodeBits;

	MXD_INT32 ( *fnDecompose)( struct _CMMBUNIT_DEFINE* pThis, MXD_UINT8* pContent, MXD_UINT32 nContentLen, MXD_UINT32 nStartBit  );
	MXD_BOOL ( *fnPreDecompose)( struct _CMMBUNIT_DEFINE* pThis );
	MXD_BOOL ( *fnPostDecompose)( struct _CMMBUNIT_DEFINE* pThis );

	union{
	struct _CMMBUNIT_DEFINE*		m_pChildUnitList;
	struct _CMMBUNIT_DEFINE*		m_pPrevUnitList;
	} m_u1;
	
	union{
	struct _CMMBUNIT_DEFINE*		m_pParentUnit;
	struct _CMMBUNIT_DEFINE*		m_pNextUnitList;
	} m_u2;

	MXD_BOOL			m_bActive;
	MXD_UINT32			m_nValue;
	MXD_UINT8*			m_pContent;
	MXD_UINT32			m_nContentBitLen;
}CMMBUNIT_DEFINE;

void InitUnitListStorage( void );
void ClearUnitListStorage( void );

CMMBUNIT_DEFINE* FrameDecompose( MXD_UINT8* pContent, MXD_UINT32 nContentLen, MXD_INT32 *pEatenBit  );
CMMBUNIT_DEFINE* FrameHeaderDecompose( MXD_UINT8* pContent, MXD_UINT32 nContentLen, MXD_INT32 *pEatenBit  );
CMMBUNIT_DEFINE* SubFrameDecompose( MXD_UINT8* pContent, MXD_UINT32 nContentLen, MXD_INT32 *pEatenBit  );
CMMBUNIT_DEFINE* EmgMsgDecompose( MXD_UINT8* pContent, MXD_UINT32 nContentLen, MXD_INT32 *pEatenBit  );

CMMBUNIT_DEFINE* FindUnitFromChild( CMMBUNIT_DEFINE* pUnitNode, const MXD_INT8* pUnitName );
CMMBUNIT_DEFINE* FindUnitFromList( CMMBUNIT_DEFINE* pUnitList, const MXD_INT8* pUnitName );
CMMBUNIT_DEFINE* GetNextSiblingInList( CMMBUNIT_DEFINE* pUnitList );

#ifdef __cplusplus
}
#endif

#endif /* __MXD_CMMBDemuxer_H__ */
